
require 'find'
	module Find
	  def match(*paths)
	    matched = []
	    find(*paths) { |path| matched << path if yield path }
	    return matched
	  end
	  module_function :match
	end	

	Find.match("./") do |p|
	  if File.file? p
	    open(p)  do |f|
          ext = p[-4...p.size]
          if ext && ext.downcase == ".sql"
           l = f.readlines
           for t in (l.size-6...l.size-1)
               #if ((l[t]!=nil) &&(l[t]="@"))
               if l[t]!=nil
                   if l[t].downcase =~/call.*/ || l[t].downcase =~/grant.*/
                       grants = l[t]
                   end
              end
          end
          
          if grants==nil || (grants[0,4].downcase !="call" && grants[0,5].downcase !="grant" )
                      puts "without grant statement:  "+p 
          else
              match = Regexp.compile('\/(.*)\.sql').match(p.downcase)
              checkname=Regexp.compile(match[1]).match(grants.downcase)
              if(!checkname)
                puts "file name not smame: "+p 
              end
           end
           
           end
        end
	  else
	    false
	  end
	end


